package com.joshondesign.sdljava.gfx.effects;

/**
* Created by IntelliJ IDEA.
* User: josh
* Date: 9/14/11
* Time: 2:29 AM
* To change this template use File | Settings | File Templates.
*/
public class SaturationFilter extends ImageFilter {
    private double scale = 0.5;

    public long[] apply(long r, long g, long b, long a) {
        double invScale = 1.0-scale;
        double value = (r*0.3 + g*0.1 + b*0.6);
        return new long[]{
                (long)(value*scale + r*invScale)
                ,(long)(value*scale + g*invScale)
                ,(long)(value*scale + b*invScale)
                ,(long)(value*scale + a*invScale)
        };
    }

    public void setValue(double value) {
        this.scale = value;
        this.dirty = true;
    }
}
